﻿Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel
Imports NHibernate

Namespace Dominio
    <Serializable()> _
    Public Class Posta

#Region "Atributos privados"

        Private _PostaID As Long
        Private _VueloVuelta As Vuelo
        Private _VueloIda As Vuelo
        Private _CantidadAuxiliaresSubscriptos As Integer
        Private _CantidadJefesCabinaSubscriptos As Integer
        Private _CantidadComisariosSubscriptos As Integer
        Private _TipoPosta As ETipoPosta
        Private _Nombre As String

#End Region

#Region "Propiedades"

        Public Overridable Property PostaID() As Long
            Get
                Return _PostaID
            End Get
            Set(ByVal value As Long)
                _PostaID = value
            End Set
        End Property

        Public Overridable Property VueloVuelta() As Vuelo
            Get
                If _VueloVuelta Is Nothing Then
                    _VueloVuelta = New Vuelo
                End If
                Return _VueloVuelta
            End Get
            Set(ByVal value As Vuelo)
                _VueloVuelta = value
            End Set
        End Property

        Public Overridable Property VueloIda() As Vuelo
            Get
                If _VueloIda Is Nothing Then
                    _VueloIda = New Vuelo
                End If
                Return _VueloIda
            End Get
            Set(ByVal value As Vuelo)
                _VueloIda = value
            End Set
        End Property

        Public Overridable Property CantidadAuxiliaresSubscriptos() As Integer
            Get
                Return _CantidadAuxiliaresSubscriptos
            End Get
            Set(ByVal value As Integer)
                _CantidadAuxiliaresSubscriptos = value
            End Set
        End Property

        Public Overridable Property CantidadJefesCabinaSubscriptos() As Integer
            Get
                Return _CantidadJefesCabinaSubscriptos
            End Get
            Set(ByVal value As Integer)
                _CantidadJefesCabinaSubscriptos = value
            End Set
        End Property

        Public Overridable Property CantidadComisariosSubscriptos() As Integer
            Get
                Return _CantidadComisariosSubscriptos
            End Get
            Set(ByVal value As Integer)
                _CantidadComisariosSubscriptos = value
            End Set
        End Property

        Public Overridable Property TipoPosta() As ETipoPosta
            Get
                Return _TipoPosta
            End Get
            Set(ByVal value As ETipoPosta)
                _TipoPosta = value
            End Set
        End Property

        Public Overridable Property Nombre() As String
            Get
                Return _Nombre
            End Get
            Set(ByVal value As String)
                _Nombre = value
            End Set
        End Property

#End Region

#Region "Metodos"

        Public Overridable Sub GetById(ByRef objPosta As Posta)
            Dim session As ISession = Nothing
            Try
                session = NHibernateHelper.OpenSession
                objPosta = DirectCast(session.Get(GetType(Posta), objPosta.PostaID), Posta)

            Catch ex As Exception
                Throw
            Finally
                session.Close()
            End Try
        End Sub

        Public Shared Function GetDescripcionTipoPosta(ByVal TipoPostaID As ETipoPosta) As String
            Select Case TipoPostaID
                Case ETipoPosta.Cabotaje
                    Return "Cabotaje"
                Case ETipoPosta.Internacional
                    Return "Internacional"
                Case ETipoPosta.Cabotaje_Internacional
                    Return "Cabotaje - Internacional"
                Case Else
                    Return "Desconocido"
            End Select
        End Function

        Public Overridable Function Clonar() As Posta
            Dim oPostaAux As New Posta
            oPostaAux.PostaID = Me.PostaID
            oPostaAux.CantidadAuxiliaresSubscriptos = Me.CantidadAuxiliaresSubscriptos
            oPostaAux.CantidadComisariosSubscriptos = Me.CantidadComisariosSubscriptos
            oPostaAux.CantidadJefesCabinaSubscriptos = Me.CantidadJefesCabinaSubscriptos
            oPostaAux.VueloIda = Me.VueloIda
            oPostaAux.Nombre = Me.Nombre
            oPostaAux.TipoPosta = Me.TipoPosta
            oPostaAux.VueloVuelta = Me.VueloVuelta

            Return oPostaAux
        End Function

#End Region

    End Class
End Namespace

